package com.xiaoma.tpo.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.MkListeningQuestion;

@Repository
public class MkListeningQuestionDao extends BaseDaoImpl<MkListeningQuestion>{

private static final Logger LOG = LoggerFactory.getLogger(MkListeningQuestionDao.class);
    
    @SuppressWarnings("unchecked")
    public List<MkListeningQuestion> findByTpoId(int tpoId) {
        String sql = "SELECT b.* FROM mk_listening a left join mk_listening_question b on a.id = b.mk_listening_id where a.mk_tpo_id = ?";
        LOG.info("SQL:{} PARAMS:{}", sql, tpoId);
        List<?> result = jdbcTemplate.query(sql, new DefaultRowMapper(MkListeningQuestion.class, getNameHandler()), tpoId);
        return (List<MkListeningQuestion>)result;
    }
}
